package com.woniu.platform.contorller;

import com.woniu.aop.OperationLogAnnotation;
import com.woniu.platform.entity.PlatformOrderForm;
import com.woniu.platform.entity.PlatformShop;
import com.woniu.platform.service.PlatformShopService;
import com.woniu.util.utils.HttpResult;
import com.woniu.util.utils.RequestResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/platformShop")
public class PlatformShopController {

    @Autowired(required = false)
    private PlatformShopService platformShopService;

    /**
     * 新增商品
     * @param platformShop
     * @return
     */
    @PostMapping("/insertGood")
    public HttpResult insertGood(@RequestBody PlatformShop platformShop){
        return platformShopService.insertGood(platformShop);
    }

    /**
     * 修改商品
     * @param platformShop
     * @return
     */

    @PostMapping("/updateGood")
    @OperationLogAnnotation(operModul = "商品模块-修改商品", operType = "修改", operDesc = "修改一件商品")//操作日志注释
    @ApiOperation(value = "修改一件商品", notes = "这是用来修改一件商品的功能")//基于swagger 用于扩展操作描述
    public HttpResult updateGood(@RequestBody PlatformShop platformShop){
        return platformShopService.updateGood(platformShop);
    }

    /**
     * 根据商品id查询
     * @param goodId
     * @return
     */
    @GetMapping("/queryGoodById")
    public HttpResult selectGoodById(int goodId){
        return platformShopService.selectGoodById(goodId);
    }

    /**
     * 查询带分页
     * @param requestResult
     * @return
     */
    @PostMapping("/queryGood")
    public HttpResult selectGoods(@RequestBody RequestResult<PlatformShop> requestResult){
        return platformShopService.selectGoods(requestResult);
    }

    /**
     * 兑换商品
     * @param platformOrderForm
     * @return
     */
    @PostMapping("/exchangeGoods")
    public HttpResult exchangeGoods(@RequestBody PlatformOrderForm platformOrderForm){
        return platformShopService.exchangeGoods(platformOrderForm);
    }
}
